<style>
    .footer-home{display: none}
    .explain{margin-top: 10px;}
    .explain p{padding:0.1rem 0.47rem}
</style>
<header>
    <a href="javascript:history.back();">
        <i class="iconfont icon-xialalan-copy"></i>
    </a>
    <span>提现</span>
</header>
<form id="pd_cash">
<div class="container" style="margin-top: 30px;">
    <ul class="info">
        <li class="info_li"><span id="p_type"><?php echo $_GET['pd_type']=='ali'?'支付宝':'微信号'?></span>：<input class="info_put" type="text"  name="pdc_number" placeholder="请输入" /></li>
        <li class="info_li">姓 名：<input class="info_put" type="text" name="pdc_user_name" placeholder="请输入" /></li>
        <li class="info_li">身份证：<input class="info_put" type="text" name="member_idcard" placeholder="请输入" /></li>
    </ul>
</div>
<div class="draw_info">
    <div  class="draw">
        <p>提现金额</p>
        <p>￥<input class="color_red" name="pdc_amount" onkeyup="num(this)" type="text"/></p>
    </div>
    <p>提现金额余额￥<?php echo $output['merchant_info']['all_money']; ?>，<span class="color_red">全部提现</span></p>
</div>
    <input type="hidden" name="form_submit" value="ok">
    <input type="hidden" name="pdc_type" value="<?php echo $_GET['pd_type']; ?>">
<a id="sub_but" class="a_btn">提现</a>
</form>
<div  class='explain' >
    <p>提现说明:</p>
    <p style="color: red">提现需要收取手续费</p>
    <p>你当前费率(<?php echo ($output['merchant_info']['pd_tariff']).'%'; ?>)</p>
</div>
<script>
    var pd_form = $("#pd_cash");
    $("#sub_but").click(function(){
         if($.trim(pd_form.find('input[name="pdc_number"]').val()) == ''){
             popAlert($("#p_type").text()+'不能为空');
             return;
         }else if($.trim(pd_form.find('input[name="pdc_user_name"]').val()) == ''){
             popAlert('收款人姓名不能为空');
             return;
         }else if($.trim(pd_form.find('input[name="member_idcard"]').val()) == ''){
             popAlert('收款人身份证不能为空');
             return;
         }else if($.trim(pd_form.find('input[name="pdc_amount"]').val()) == ''){
             popAlert('提现金额不能为空');
             return;
         }else if($.trim(pd_form.find('input[name="pdc_amount"]').val())><?php echo $output['merchant_info']['all_money']; ?>){
             popAlert('提现金额不能大于可用金额');
             return;
         }else if($.trim(pd_form.find('input[name="pdc_amount"]').val())==0){
             popAlert('提现金额不能为0');
             return;
         }
        $.ajax({
            url: 'index.php?act=merchant&op=pd_cash',
            type: 'POST',
            data: pd_form.serialize(),
            dataType: 'json',
            async: false,
            success: function (data) {
                if(data.ecode==0){
                    popAlert(data.msgs);
                }else{
                    popAlert('提交成功', function () {
                        location.href = 'index.php?act=merchant&op=wallet';
                    });
                }
            }
        })

    })
    //全部提现
    $('.color_red').click(function(){
        $("[name='pdc_amount']").val(<?php echo $output['merchant_info']['all_money']; ?>);
    });
    function num(obj){
        obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符
        obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个, 清除多余的
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数
    }
</script>